<?php
namespace app\common\model;

use think\Model;
use traits\model\SoftDelete;

class TemplateGroupModel extends Model
{
	use SoftDelete;
	
	protected $autoWriteTimestamp='datetime';
	protected $updateTime = false;
	protected $dateFormat = "Y-m-d H:i:s";
	protected $field = true;
	//分类
	public function category(){
		return $this->belongsTo('TemplateCategoryModel','category_id','category_id')->field('category_id,name,p_category_id');
	}
	//表头
	public function header(){
		return $this->belongsTo('TemplateHeaderModel','header_id','header_id')->field('header_id,name,content');
	}
	//表尾
	public function footer(){
		return $this->belongsTo('TemplateFooterModel','footer_id','footer_id')->field('footer_id,name,content');
	}
	//课题
	public function template(){
		return $this->belongsTo('TemplateModel','template_id','id')->field('name,id,progress,description');
	}
	public function appuser(){
		return $this->hasOne('AppUserModel','id','user_id')->field('realName');
	}
}